﻿<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title> 名医信息编辑 </title>
    <link rel="stylesheet" type="text/css" href="/css/style.css" />

    <style type="text/css">
        /*字体样式*/
        *, body {
            margin: 0px;
            font-family: '微软雅黑',serif;
        }
        /*超链接样式*/
        a:link{
            color:red;
        }
        a:visited{
            color:#008000;
        }
        a:active{
            color:cadetblue;
        }
        a:hover{
            color: #a71d5d;
        }
    </style>
    <script src="/js/jquery-1.10.2.min.js"></script>
    <script src="/js/jquery.form.js"></script>
    <script src="/js/generic.js"></script>
</head>

<body>
<table class="maintable">
    <tr>
        <td class="rightmaintd" valign="top">
<!--            返回名医信息页面超链接-->
            <div class="searchdiv">
                <a href="/myxx">&lt; 返回</a>
                <div class="rightsearchdiv"><!-- name --></div>
            </div>
            <table class="leftrighttable" border="0">
                <tr>
                    <td class="lefttdtable" width="50%" valign="top">
<!--                        编辑表主体-->
                        <table cellpadding="6">
                            <tr>
                                <td class="tdname">名医姓名</td>
                                <td>
                                    <input type="text" id="xingming" class="textinput" maxlength="50" th:value="${myxx.getXingming()}">
                                </td>
                            </tr>
                            <tr>
                                <td class="tdname">朝代</td>
                                <td>
                                    <select id="chaodai" class="textselect">
                                        <option value="" th:selected="${myxx.getChaodai()==''}">请选择</option>
                                        <option value="1979年后" th:selected="${myxx.getChaodai()=='1979年后'}">1979年后</option>
                                        <option value="1949-1979年" th:selected="${myxx.getChaodai()=='1949-1979年'}">1949-1979年</option>
                                        <option value="民国" th:selected="${myxx.getChaodai()=='民国'}">民国</option>
                                        <option value="清" th:selected="${myxx.getChaodai()=='清'}">清</option>
                                        <option value="明" th:selected="${myxx.getChaodai()=='明'}">明</option>
                                        <option value="元" th:selected="${myxx.getChaodai()=='元'}">元</option>
                                        <option value="宋" th:selected="${myxx.getChaodai()=='宋'}">宋</option>
                                        <option value="隋唐五代" th:selected="${myxx.getChaodai()=='隋唐五代'}">隋唐五代</option>
                                        <option value="魏晋南北朝" th:selected="${myxx.getChaodai()=='魏晋南北朝'}">魏晋南北朝</option>
                                        <option value="汉" th:selected="${myxx.getChaodai()=='汉'}">汉</option>
                                        <option value="先秦" th:selected="${myxx.getChaodai()=='先秦'}">先秦</option>
                                        <option value="上古" th:selected="${myxx.getChaodai()=='上古'}">上古</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td class="tdname">籍贯</td>
                                <td><input type="text" id="jiguan" class="textinput" maxlength="50" th:value="${myxx.getJiguan()}"></td>
                            </tr>

                            <tr>
                                <td class="tdname">行医地点</td>
                                <td><input type="text" id="xinyididian" class="textinput" maxlength="50" th:value="${myxx.getXinyididian()}"></td>
                            </tr>
                            <tr>
                                <td class="tdname">医家流派</td>
                                <td>
                                    <select id="yijialiupai" class="textselect">
                                        <option value="" th:selected="${myxx.getYijialiupai()==''}">请选择</option>
                                        <option value="伤寒派" th:selected="${myxx.getYijialiupai()=='伤寒派'}">伤寒派</option>
                                        <option value="脾胃派" th:selected="${myxx.getYijialiupai()=='脾胃派'}">脾胃派</option>
                                        <option value="滋阴派" th:selected="${myxx.getYijialiupai()=='滋阴派'}">滋阴派</option>
                                        <option value="寒凉派" th:selected="${myxx.getYijialiupai()=='寒凉派'}">寒凉派</option>
                                        <option value="温补派" th:selected="${myxx.getYijialiupai()=='温补派'}">温补派</option>
                                        <option value="温病派" th:selected="${myxx.getYijialiupai()=='温病派'}">温病派</option>
                                        <option value="火神派" th:selected="${myxx.getYijialiupai()=='火神派'}">火神派</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td class="tdname">特点/备注</td>
                                <td><input type="text" id="tedian" class="textinput" maxlength="50" th:value="${myxx.getTedian()}"></td>
                            </tr>
                            <tr>
                                <td class="tdname">师承</td>
                                <td><input type="text" id="shicheng" class="textinput" maxlength="50" th:value="${myxx.getShicheng()}"></td>
                            </tr>
                            <tr>
                                <td class="tdname">弟子</td>
                                <td><input type="text" id="dizi" class="textinput" maxlength="50" th:value="${myxx.getDizi()}"></td>
                            </tr>
                            <tr>
                                <td class="tdname">所在气候</td>
                                <td><input type="text" id="suoshuoqihou" class="textinput" maxlength="50" th:value="${myxx.getSuoshuoqihou()}"></td>
                            </tr>

                        </table>
                    </td>
                    <td class="righttdtable" width="50%" valign="top"></td>
                </tr>

            </table>
<!--保存按钮-->
            <div class="shenhediv">
                <input type="button" value="保 &nbsp; &nbsp; 存" class="baocunbtn5" onclick="save()">
                <input type="button" value="审核通过" id="btnValidate" class="shenhebtn" onclick="shenhe()"> &nbsp;&nbsp;
                <span id="lrxx"></span>
            </div>

        </td>
    </tr>
</table>
<p th:text="${myxx.getId()}" class="shownone" id="Id"></p>

</body>
</html>
<script type="text/javascript">
    var xingming,chaodai,jiguan,xinyididian,yijialiupai,tedian,shicheng,dizi,suoshuoqihou;
    var idData=document.getElementById('Id').textContent;
    function save(){
        xingming = document.getElementById('xingming').value;
        if(xingming==""){
            alert("请输入名医姓名！");
            return;
        }
        chaodai = document.getElementById('chaodai').value;
        if(chaodai=="")
            chaodai=null;
        jiguan=document.getElementById('jiguan').value;
        if(jiguan=="")
            jiguan=null;
        xinyididian = document.getElementById('xinyididian').value;
        if(xinyididian=="")
            xinyididian=null;
        yijialiupai = document.getElementById('yijialiupai').value;
        if(yijialiupai=="")
            yijialiupai=null;
        tedian = document.getElementById('tedian').value;
        if(tedian=="")
            tedian=null;
        shicheng=document.getElementById('shicheng').value;
        if(shicheng=="")
            shicheng=null;
        dizi=document.getElementById('dizi').value;
        if(dizi=="")
            dizi=null;
        suoshuoqihou=document.getElementById('suoshuoqihou').value;
        if(suoshuoqihou=="")
            suoshuoqihou=null;
        // 创建要发送的数据对象
        var data = {
            id: idData,
            xingming: xingming,
            chaodai: chaodai,
            jiguan: jiguan,
            xinyididian: xinyididian,
            yijialiupai: yijialiupai,
            tedian: tedian,
            shicheng: shicheng,
            dizi: dizi,
            suoshuoqihou: suoshuoqihou
        };
        console.log(data);
        // 发送 POST 请求
        var xhr = new XMLHttpRequest();
        xhr.open('PUT', '/myxx/', true);
        xhr.setRequestHeader('Content-Type', 'application/json');
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4 && xhr.status === 200) {
                // 请求完成并成功处理后的回调函数
                console.log('数据已成功发送至后端');
                alert("修改成功！");
            }
        };
        xhr.send(JSON.stringify(data));
    }
    function shenhe(){
        var data = {
            shenhe: "通过",
            shr: "admin"
        };
        // 发送 POST 请求
        var xhr = new XMLHttpRequest();
        xhr.open('PUT', '/myxx/'+idData, true);
        xhr.setRequestHeader('Content-Type', 'application/json');
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4 && xhr.status === 200) {
                // 请求完成并成功处理后的回调函数
                console.log('数据已成功发送至后端');
                alert("已审核！");
            }
        };
        xhr.send(JSON.stringify(data));
    }
</script>